import { defineStore } from "pinia";

export const useStore = defineStore('store', {
    persist: {
        enabled: true,
        strategies: [
            {
                // 缓存的模块名称
                key: "store",
                // 保存位置，默认保存在sessionStorage
                storage: localStorage,
                // 缓存哪些状态
                paths: ["token", "username", "type"]
            }
        ]
    },
    getters: {
        islogin(state) {
            return !!state.token
        }
    },
    state: () => {
        return {
            token: '',
            username: "",
            type: "",//登录类型
            routes: [],
        }
    },
    // actions: {
    //     changUserinfo(payload) {
    //         this.username = payload
    //     }
    // }
})